<!-- 更换手机号码 -->
<template>
  <div id="" class="changeName">
    <h2 v-title="'验证码'"></h2>
    <h2>您的新手机号码是？</h2>
    <div class="inputDiv">
      <p>更换新手机号后下次登录使用新手机号</p>
      <input type="text" name="" v-model="newMobile" placeholder="请输入新手机号码">
    </div>

    <div class="fixedBottom">
      <button type="button" name="button" class="blockBtn" @click="submitMobile">确定</button>
    </div>
    <comfirm-login
    :comfirmTitle="comfirmTitle" v-if="isShow"
    @comfirmEvent="comfirmEvent"></comfirm-login>
  </div>
</template>
<script>
import { mobileTest } from '@/util/util.js';
import { Toast } from 'mint-ui';
import comfirmLogin from '@/components/comfirm.vue';
import {reLoginWX} from '@/util/util.js';
export default {
  name: "",
  data: () => ({
    newMobile:'',
    isShow:false,
    comfirmTitle:{
      comfirmTop:'提示',
      comfirmCon:'新手机绑定成功',
      comfirmBtn:['取消','确认'],
    }
  }),
  components: {
    comfirmLogin,
  },
  methods: {
    submitMobile() {
      let that = this;
      let newMobile = that.newMobile;
      if(mobileTest(newMobile)){
        Toast('手机号码错误，请重新输入');
        return false;
      }
      network.post(configUrl.BINDNEWMOBILE_URL,{mobile:newMobile},function(res){
        console.log(res);
        if(res.code==401) {
          reLoginWX();
        }else{
          that.isShow = true;
        }
      },function(err){
        console.log(err);
      });
      console.log();
    },
    comfirmEvent(data){
      console.log(data);
      let that = this;
      that.isShow = false;
      window.localStorage.removeItem('userToken');    //清除缓存对应缓存
      that.$router.go(-3);
    }
  }
}
</script>
<style lang="scss" scoped src="./memberSetFile.scss"></style>
